package com.atsea.boot.controller;

import com.atsea.boot.bean.Pet;
import com.atsea.boot.dao.StudentMapper;
import com.atsea.boot.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author linhaizeng
 * @Description 学习RestController
 * @date 2021/11/19-10:41 下午
 */
/**
 * @RestController 是
 * @Controller
 * @ResponseBody 的合体
 *
 **/

@RestController
public class HelloController {

    @Autowired
    @Qualifier("dog")
    Pet dog;


    private StudentMapper studentMapper;

    @Qualifier("studentMapper")
    @Autowired
    public void setStudentMapper(StudentMapper studentMapper){
        this.studentMapper = studentMapper;
    }


    @RequestMapping("/hello")
    public String hand01(){
        dog.setName("hahha");
        return dog.getName();
    }

    @RequestMapping("/insert")
    public String hand02(){
        Student student = new Student();
        student.setAge(10);
        studentMapper.insert(student);
        return "success";
    }
}
